﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITMan
{
    /// <summary>
    /// IMC密码操作类
    /// </summary>
    class IMCPassWord
    {
        /// <summary>
        /// 密码生成方法
        /// </summary>
        /// <param name="para">明文</param>
        /// <returns>密文</returns>
        public static string Gen(string para)
        {
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.WorkingDirectory = Environment.CurrentDirectory+@"\dbman";
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.UseShellExecute = false;		//不用Shell启动
            p.StartInfo.RedirectStandardInput = true;	//输入重定向
            p.StartInfo.RedirectStandardOutput = true;	//输出重定向 
            p.StartInfo.CreateNoWindow = true; 			//不显示窗口

            p.Start();
            p.StandardInput.WriteLine("dbman -encrypt " + para);
            p.StandardInput.WriteLine("exit");
            string s = p.StandardOutput.ReadLine();
            s = p.StandardOutput.ReadLine();
            s = p.StandardOutput.ReadLine();
            s = p.StandardOutput.ReadLine();
            s = p.StandardOutput.ReadLine();
            p.Close();
            return s;
        }
    }
}
